package com.daka.entity;

import com.daka.tools.CodeMap;
import com.daka.tools.ConfigUtil;
import com.daka.tools.DateUtil;
import lombok.Data;
import lombok.ToString;
import org.apache.ibatis.type.Alias;

import java.util.Date;

@Data
@ToString
@Alias(value = "group")
@SuppressWarnings("unused")
public class Group {

    private Long id;
    private String groupCode;
    private String name;
    private String shortName;
    private Integer volunteers;
    private Integer actvitys;
    private Integer times;
    private Integer badComment;
    private String province;
    private String city;
    private String district;
    private Date createTime;
    private Integer delStatus;
    private Integer goodComment;
    private Integer liveness;
    private String logo;
    private Integer mediumComment;
    private String monitor;
    private String phone;
    private String regAddress;
    private String serviceField;
    private String setupDate;
    private Long volunteerId;
    private Long oldid;
    private String code;
    private String codeImg;
    private String platform;
    private String client;
    private String addressCode;
    private String demo;

    public static Group build(Organization1 organization1) {
        Group group = new Group();
        group.setGroupCode(organization1.getGroupcode());
        group.setName(organization1.getName());
        group.setShortName(organization1.getShortname());
        group.setVolunteers(organization1.getMembercounts());
        group.setActvitys(organization1.getActivitycounts());
        group.setTimes(organization1.getTimes());
        group.setProvince(organization1.getProvince());
        group.setCity(organization1.getCity());
        group.setDistrict(organization1.getDistrict());
        group.setDelStatus(organization1.getDelstatus());
        group.setDemo(organization1.getDemo());
        group.setLiveness(0);
        group.setLogo(organization1.getLogo());
        group.setGoodComment(0);
        group.setMediumComment(0);
        group.setBadComment(0);
        group.setMonitor(organization1.getMonitor());
        group.setPhone(organization1.getPhone());
        group.setRegAddress(organization1.getProvince() + " " + organization1.getCity() + "" + organization1.getDistrict());
        try{
            group.setServiceField(CodeMap.getUserSkillValue(organization1.getServicetype()));//服务领域
        }catch (Exception e){
            e.printStackTrace();
        }
        try {
            if (organization1.getCreateTime() != null) {
                group.setCreateTime(DateUtil.getDateFormString(organization1.getCreateTime()));
            }
        } catch (Exception e) {
            group.setCreateTime(new Date());
            e.printStackTrace();
        }
        group.setSetupDate(organization1.getRegdate());
        if (organization1.getId() != null) {
            group.setOldid(Long.valueOf(organization1.getId()));
        }
        group.setCode(organization1.getLeadercode());
        group.setClient(ConfigUtil.CLIENT_ID);
        return group;
    }
}




